﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Users.aspx.cs" Inherits="Main_Utilities_Users" %>
<%@ Register Src="~/User Controls/PageHeading.ascx" TagName="heading" TagPrefix="acc" %>
   
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
     <link href="../../Styles/accounts.css" rel="Stylesheet" type="text/css" />
     <script src="../../JavaScript/ModalPopups.js" type="text/javascript"></script>
     <script type="text/javascript" language="javascript">     
       function ModalPopupsWait() 
       {  
            ModalPopups.Indicator("idIndicator2",  
            "Please wait",  
            "<div style=''>" +  
            "<div style='float:left;'><img src='../../Images/spinner.gif'></div>" +   
            "<div style='float:left; padding-left:10px;'>" +   
            "Saving User Information... <br/>" +   
            "This may take few seconds." +   
            "</div>",   
            {  
               width: 300,  
              height: 100  
            }  
            );   
            setTimeout('ModalPopups.Close(\"idIndicator2\");', 3000);  
        } 
          
        
        function ModalPopupsAlert()
        {  
           ModalPopups.Alert("jsAlert1",  
           document.getElementById("hidHeading").value,  
           "<div style='padding:25px; width:150px;'>"+document.getElementById("hidMessage").value+"</div>",             
           {  
             okButtonText: "OK"  
           }  
           );  
        }     
  
  function getCheckedRadio() 
  {
      var radioButtons = document.getElementsByName("RBtnListActive");
      for (var x = 0; x < radioButtons.length; x ++) 
      {
        if (radioButtons[x].checked) 
        {
            if(radioButtons[x].value=='0')
            {
              var ddlGroup = document.getElementById("DdlGroup")
              ddlGroup.selectedIndex=0;
              ddlGroup.disabled=true;  
            }
            else
            {
              var ddlGroup = document.getElementById("DdlGroup")
              ddlGroup.selectedIndex=0;
              ddlGroup.disabled=false;  
            }          
        }
      }
   }
  
</script>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" EnablePartialRendering="true" EnablePageMethods="true" runat="server">
        </asp:ScriptManager>
    <div class="divhead">
        <acc:heading ID="pagehead" runat="server" HeadingText="User Master" />
    </div>
     <%--<asp:UpdateProgress DynamicLayout="false" AssociatedUpdatePanelID="UpdatePanel1" ID="UpdProgress" runat="server">
        <ProgressTemplate>
       
        </ProgressTemplate>
        </asp:UpdateProgress>--%>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
        <div align ="center"><asp:Label ID="lblMsg" runat="server" Font-Bold="true"></asp:Label></div> 
        <asp:HiddenField ID="hidHeading" runat="server" />
        <asp:HiddenField ID="hidMessage" runat="server" />
        <table class="tablecontent"  style= "width:60%;margin-left:20%; margin-right:20%;" >
              <tr>
                <td class="headtd" colspan="4"> 
                   User Details
               </td>
             </tr>
             <tr>
                <td> Email <span class="required">*</span> </td>
                <td> <asp:TextBox ID="TxtEmail" runat="server" Width="120px" ToolTip="Enter Email" ValidationGroup="name" CssClass ="input" ></asp:TextBox>
                      <asp:RequiredFieldValidator ID="RFVCategoryName" runat="server" ValidationGroup="name" ControlToValidate="TxtEmail" ErrorMessage="*" ></asp:RequiredFieldValidator>
                      <asp:RegularExpressionValidator ID="regEmail" runat="server" ControlToValidate="TxtEmail" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" 
                        Display="Dynamic" ErrorMessage="Invalid Email" ValidationGroup="name"></asp:RegularExpressionValidator>
                </td>
                 <td> Password<span class="required">*</span> </td>
                <td> <asp:TextBox ID="TxtPassword" runat="server" Width="120px" ToolTip="Enter Password" ValidationGroup="name" CssClass ="input" TextMode="Password"></asp:TextBox>
                      <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ValidationGroup="name" ControlToValidate="TxtPassword" ErrorMessage="*" ></asp:RequiredFieldValidator>
                </td>
            </tr>
            <tr>
                <td> First Name <span class="required">*</span> </td>
                <td> <asp:TextBox ID="TxtFirstName" runat="server" Width="120px" ToolTip="Enter First Name" ValidationGroup="name" CssClass ="input" ></asp:TextBox>
                      <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ValidationGroup="name" ControlToValidate="TxtFirstName" ErrorMessage="*" ></asp:RequiredFieldValidator>
                </td>
                 <td> Last Name<span class="required">*</span> </td>
                <td> <asp:TextBox ID="TxtLastName" runat="server" Width="120px" ToolTip="Enter Last Name" ValidationGroup="name" CssClass ="input" ></asp:TextBox>
                      <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ValidationGroup="name" ControlToValidate="TxtLastName" ErrorMessage="*" ></asp:RequiredFieldValidator>
                </td>
            </tr>
             <tr>
                <td>Active As </td>
                <td> 
                    <asp:RadioButtonList ID="RBtnListActive" runat="server" RepeatDirection="Horizontal">
                        <asp:ListItem onclick="return getCheckedRadio();" Text="Group"  Value="1" Selected="True" ></asp:ListItem>
                        <asp:ListItem onclick="return getCheckedRadio();" Text="Individual" Value="0"></asp:ListItem>
                    </asp:RadioButtonList>
                </td>
                 <td> Group</td>
                <td> 
                   <asp:DropDownList ID="DdlGroup" runat="server"></asp:DropDownList>
                </td>
            </tr>
              <tr>
               <td colspan="4" align="center">
                    <asp:Button ID="btnSubmit" runat="server" Text="Create" CssClass="button"  ValidationGroup="name"
                        onclick="btnSubmit_Click" />                  
                </td>
            </tr>
            
       </table>
       
       </ContentTemplate>
       </asp:UpdatePanel>
       <div style="width:80%; margin-left:10%; margin-right:10%; margin-top:30px">
       <asp:GridView ID="grdDisplay" runat="server" AutoGenerateColumns="false" 
               AllowPaging="true" PageSize="10"
       CssClass="gridview" AlternatingRowStyle-CssClass="gridview_alternate" DataKeyNames="UserId" 
       onpageindexchanging="grdDisplay_PageIndexChanging" 
               onselectedindexchanged="grdDisplay_SelectedIndexChanged">
           <Columns>
           <asp:TemplateField HeaderText="S.No.">
               <ItemTemplate>
               <%# Container.DataItemIndex+1 %>
               </ItemTemplate>
           </asp:TemplateField>
           <asp:BoundField DataField="UserName" HeaderText="User Name" />
           <asp:BoundField DataField="FirstName" HeaderText=" First Name" />
           <asp:BoundField DataField="LastName" HeaderText="Last Name" />
           <asp:BoundField DataField="GroupName" HeaderText="Group Name" />
           <asp:CommandField HeaderText="Edit" SelectText="<img src='../../Menu/images/edit_user.png'/>" ShowHeader="true" ShowSelectButton="true" ItemStyle-HorizontalAlign="Center" />           
           </Columns>
       </asp:GridView>
       
       </div>
    </form>
</body>
</html>

